﻿using System;
using System.Collections.Generic;
using System.Text;
using pos.entity;
using System.Collections;
namespace idea.tools
{
    class ReportItem
    {
         public string cn1;
         public string cn2;
         public string cn3;
         public object outObj;
    }
    class ReportTool
    {
        private Hashtable m_reportDatas;
        private Hashtable m_commodityDatas;

        public Hashtable ReportDatas
        {
            get { return m_reportDatas; }
         
        }
        public Hashtable CommodityDatas
        {
            get { return m_commodityDatas; }

        }
         
        public ReportTool()
        {
            m_reportDatas = new Hashtable();
            m_commodityDatas = new Hashtable();
        }
        public ReportItem getItem(string id)
        {
            string cn1,cn2,cn3;
            t_commodity t = m_commodityDatas[id] as t_commodity;
            if (t == null)
            {
                t = t_commodity.GetByCommodityID(id);//.getEntity(string.Format(" where commodityID='{0}'", id));
                if(t==null)
                    throw new Exception("商品不存在id:"+id);
                else
                m_commodityDatas.Add(id, t);
                
            }
           // else
             //   m_commodityDatas.Add(id, t);
            if (t == null)
            {
                cn1 = "商品库中不存在";
                cn2 = "";
                cn3 = "";
            }
            else
            {

                cn1 = t.commodityClass1;
                cn2 = t.commodityClass2;
                cn3 = t.commodityClass3;
            }
            ReportItem item = (ReportItem)m_reportDatas[cn1 + cn2 + cn3];
            if (item == null)
            {
                item = new ReportItem();
                item.cn1 = cn1;
                item.cn2 = cn2;
                item.cn3 = cn3;
             
                item.outObj = null;
                m_reportDatas.Add(cn1 + cn2 + cn3, item);
            }
            return item;
        }
    }
}
